<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<header th:replace="inc/header"></header>

<body th:with="menu='conf'">
<nav th:replace="inc/nav"></nav>

<div class="container-fluid">
  <div class="row">
    <div th:replace="inc/sidebar"></div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <h1 class="page-header">全局配置</h1>
      <form class="form-horizontal" id="formConfig">
        <input type="hidden" name="jsbh" id="jsbh" th:value="${config.jsbh}">
        <input type="hidden" name="id" id="id" th:value="${config.id}">
        
        <div class="form-group">
          <label for="mqInAddress" class="control-label col-md-3">MQ内网地址</label>
          <div class="col-md-9">
            <input type="text" name="mqInAddress" id="mqInAddress" class="form-control" th:value="${config.mqInAddress}"
                   required>
          </div>
        </div>
        <div class="form-group">
          <label for="mqOutAddress" class="control-label col-md-3">MQ外网地址</label>
          <div class="col-md-9">
            <input type="text" name="mqOutAddress" id="mqOutAddress" class="form-control" th:value="${config.mqOutAddress}"
                   required>
          </div>
        </div>
        <div class="form-group">
          <label for="mqUserName" class="control-label col-md-3">MQ用户名</label>
          <div class="col-md-9">
            <input type="text" name="mqUserName" id="mqUserName" class="form-control" th:value="${config.mqUserName}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="mqPasswd" class="control-label col-md-3">MQ密码</label>
          <div class="col-md-9">
            <input type="text" name="mqPasswd" id="mqPasswd" class="form-control" th:value="${config.mqPasswd}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="mqVirtualHost" class="control-label col-md-3">MQ vhost</label>
          <div class="col-md-9">
            <input type="text" name="mqVirtualHost" id="mqVirtualHost" class="form-control" th:value="${config.mqVirtualHost}"
                   required>
          </div>
        </div>
        <div class="form-group">
          <label for="mqPort" class="control-label col-md-3">MQ端口</label>
          <div class="col-md-9">
            <input type="text" name="mqPort" id="mqPort" class="form-control" th:value="${config.mqPort}" required>
          </div>
        </div>
        <hr>
        <div class="form-group">
          <label for="nginxInAddress" class="control-label col-md-3">nginx内网地址</label>
          <div class="col-md-9">
            <input type="text" name="nginxInAddress" id="nginxInAddress" class="form-control"
                   th:value="${config.nginxInAddress}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="nginxOutAddress" class="control-label col-md-3">nginx外网地址</label>
          <div class="col-md-9">
            <input type="text" name="nginxOutAddress" id="nginxOutAddress" class="form-control"
                   th:value="${config.nginxOutAddress}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="nginxPort" class="control-label col-md-3">nginx端口</label>
          <div class="col-md-9">
            <input type="text" name="nginxPort" id="nginxPort" class="form-control" th:value="${config.nginxPort}" required>
          </div>
        </div>
        <hr>
        <div class="form-group">
          <label for="offScreenTime" class="control-label col-md-3">自动关屏时间</label>
          <div class="col-md-9">
            <input type="text" name="offScreenTime" id="offScreenTime" class="form-control" th:value="${config.offScreenTime}"
                   required>
          </div>
        </div>
        <hr>
        <div class="form-group">
          <label for="aliveTime" class="control-label col-md-3">保活时间</label>
          <div class="col-md-9">
            <input type="text" name="aliveTime" id="aliveTime" class="form-control" th:value="${config.aliveTime}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="alivePort" class="control-label col-md-3">保活端口</label>
          <div class="col-md-9">
            <input type="text" name="alivePort" id="alivePort" class="form-control" th:value="${config.alivePort}" required>
          </div>
        </div>
        <hr>
        <div class="form-group">
          <label for="talkInAddress" class="control-label col-md-3">对讲服务器内网地址</label>
          <div class="col-md-9">
            <input type="text" name="talkInAddress" id="talkInAddress" class="form-control" th:value="${config.talkInAddress}"
                   required>
          </div>
        </div>
        <div class="form-group">
          <label for="talkOutAddress" class="control-label col-md-3">对讲服务器外网地址</label>
          <div class="col-md-9">
            <input type="text" name="talkOutAddress" id="talkOutAddress" class="form-control"
                   th:value="${config.talkOutAddress}" required>
          </div>
        </div>
        <div class="form-group">
          <label for="talkPort" class="control-label col-md-3">对讲服务器端口</label>
          <div class="col-md-9">
            <input type="text" name="talkPort" id="talkPort" class="form-control" th:value="${config.talkPort}" required>
          </div>
        </div>
        <hr>
        <div class="form-group">
          <label for="inAddress" class="control-label col-md-3">内网地址</label>
          <div class="col-md-9">
            <input type="text" name="inAddress" id="inAddress" class="form-control" th:value="${config.inAddress}" required>
          </div>
        </div>
         <div class="form-group">
          <label for="inAddress" class="control-label col-md-3">api地址</label>
          <div class="col-md-9">
            <input type="text" name="hongsenApi" id="hongsenApi" class="form-control" th:value="${config.hongsenApi}" required>
          </div>
        </div>
        
        <div class="form-group">
          <label for="shoppingMonthLimit" class="control-label col-md-3">每月购物限额</label>
          <div class="col-md-9">
            <input type="text" name="shoppingMonthLimit" id="shoppingMonthLimit" class="form-control" th:value="${config.shoppingMonthLimit}" required>
          </div>
        </div>
        
        
        <a class="btn btn-primary" id="btnSave">保存</a>
      </form>
    </div>
  </div>
</div>

<div th:replace="inc/footer"></div>
<script th:inline="javascript">
  $(function () {
    var $formConfig = $('#formConfig');
    // 表单验证
    $formConfig.validate();
    // 提交表单
    $('#btnSave').on('click', function () {
      if (!$formConfig.valid()) {
        return false;
      }
      var data = $formConfig.serializeDict();
      $.ajax({
        url: [[${#httpServletRequest.getContextPath()} + '/conf/save']],
        data: data,
        method: 'post',
        success: function () {
          alert('保存成功');
          window.location.reload();
        },
        error: function () {
          alert('保存失败');
        }
      })
    })
  });
</script>
</body>
</html>
